<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
            label-width="68px">
            <el-form-item prop="targetName">
                <el-page-header @back="goBack" content="审批记录">
                </el-page-header>
            </el-form-item>

            <el-form-item style="float: right;" v-if="type == 2">
                <el-button type="primary" size="mini" @click="handletongguo
            ">通过</el-button>
                <el-button size="mini" @click="resetbohui">驳回</el-button>
            </el-form-item>
        </el-form>



        <el-table v-loading="loading" :data="InfoProjectList" @selection-change="handleSelectionChange">
            <el-table-column label="用户名" align="center" prop="createBy" />
            <el-table-column label="文件名称" align="center" prop="fileName">
                <template slot-scope="scope">
                    <el-link type="primary" @click="xiazai(scope.row)">{{ scope.row.fileName }}</el-link>
                </template>
            </el-table-column>
            <el-table-column label="提交时间" align="center" prop="createTime" />
            <el-table-column label="备注" align="center" prop="remark" />
            <el-table-column label="审核状态" align="center" prop="status">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.info_identity_status" :value="scope.row.status" />
                </template>
            </el-table-column>

        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize" @pagination="getList" />

    </div>
</template>
<script>
import { listIdentity, listUserById, getIdentity, delIdentity, addIdentity, updateIdentity } from "@/api/InfoIdentityUp/identity";
import request from '@/utils/request'

export default {
    name: "InfoProject",
    dicts: ['info_identity', 'info_identity_status'],
    data() {
        return {
            // 遮罩层
            loading: false,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 项目信息表格数据
            InfoProjectList: [
                { projectName: "测试项目" }
            ],
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                projectName: null,

            },
            // 表单参数
            form: {},
            // 表单校验
            rules: {
            },
            questionnaireName: null,
            projectId: null
        };
    },
    created() {
        this.projectId = this.$route.query.id
        this.type = this.$route.query.type


        this.getList()
    },
    methods: {
        xiazai(row) {
            this.$download.saveAs(row.fileUrl, row.fileUrl);

        },
        handletongguo() {
            request({
                url: "/InfoIdentityUp/identity",
                method: "put",
                data: { status: 2, id: this.InfoProjectList[this.InfoProjectList.length - 1].id,currentIdentity: this.InfoProjectList[this.InfoProjectList.length - 1].currentIdentity,userId: this.InfoProjectList[this.InfoProjectList.length - 1].userId }
            }).then(res => {
                this.$message({
                    message: '已通过',
                    type: 'success'
                });
                this.getList()
                this.$router.back()

            })

        },
        resetbohui() {
            request({
                url: "/InfoIdentityUp/identity",
                method: "put",
                data: { status: 3, id: this.InfoProjectList[this.InfoProjectList.length - 1].id }
            }).then(res => {
                this.$message({
                    message: '已驳回',
                    type: 'success'
                });
                this.getList()
                this.$router.back()

            })
        },
        goBack() {
            this.$router.back()
        },
        /** 查询项目信息列表 */
        getList() {
            this.loading = true;
            listUserById(this.projectId).then(response => {
                this.InfoProjectList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        /**取消按钮 */
        cancel() {
            this.open = false;
            this.reset();
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },


        /** 详情按钮操作 审核 */
        handleDetails(row) {
            this.$router.push({
                path: '/Questionnaire/listLookDetails',
                query: { ids: row.id }
            })
        },
        /** 删除按钮操作 */
        handleDelete(row) {
            const ids = row.id || this.ids;
            this.$modal.confirm(`删除“${row.questionTitle}”?`).then(function () {
                return delInfoQuestionNaire(ids);
            }).then(() => {
                this.getList();
                this.$modal.msgSuccess("删除成功");
            }).catch(() => { this.getList(); });
        },
        /** 导出按钮操作 */
        handleExport() {
            this.download('InfoProject/InfoProject/export', {
                ...this.queryParams
            }, `InfoProject_${new Date().getTime()}.xlsx`)
        }
    }
};
</script>
<style lang="scss" scoped></style>
